//
//  YYELatestRecommandTableViewCell.m
//  YuYingEDU
//
//  Created by 胡波 on 2017/12/28.
//  Copyright © 2017年 胡波. All rights reserved.
//

#import "YYELatestRecommandTableViewCell.h"

@interface YYELatestRecommandTableViewCell ()

@property (nonatomic,strong) UIImageView *backIV;
@property (nonatomic,strong) UILabel *activeNameLabel;
@property (nonatomic,strong) UILabel *timeLabel;

@end

@implementation YYELatestRecommandTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.backIV = [[UIImageView alloc]init];
        [self.contentView addSubview:self.backIV];
        self.backIV.contentMode = UIViewContentModeScaleAspectFill;
        self.backIV.clipsToBounds = YES;
        
        self.activeNameLabel = [[UILabel alloc]init];
        self.activeNameLabel.textColor = [UIColor whiteColor];
        self.activeNameLabel.font = [UIFont systemFontOfSize:14];
        self.activeNameLabel.textAlignment = NSTextAlignmentCenter;
        [self.backIV addSubview:self.activeNameLabel];
        
        self.timeLabel = [[UILabel alloc]init];
        self.timeLabel.textColor = [UIColor whiteColor];
        self.timeLabel.font = [UIFont systemFontOfSize:10];
        self.timeLabel.numberOfLines = 0;
        self.timeLabel.textAlignment = NSTextAlignmentCenter;
        [self.backIV addSubview:self.timeLabel];
        
//        self.backIV.image = [UIImage imageNamed:@"courseHolder"];
//        self.activeNameLabel.text = @"Web前端攻城狮，点击立即参与~";
//        self.timeLabel.text = [NSString stringWithFormat:@"高级前端讲师 陈晨\n2017年12月25日18：00开讲"];
        
    }
    return self;
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.backIV makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(UIEdgeInsetsMake(0, 0, 3, 0));
    }];
    
    [self.activeNameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.backIV.centerX);
        make.bottom.equalTo(self.backIV.centerY);
    }];
    
    [self.timeLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.backIV.centerX);
        make.top.equalTo(self.backIV.centerY);
    }];
    
}

- (void)setModel:(YYELatestRecommandModel *)model {
    _model = model;
    
    [self.backIV sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"courseHolder"]];
    self.activeNameLabel.text = model.title;
    self.timeLabel.text = model.start_time;
    self.timeLabel.text = [NSString stringWithFormat:@"%@ %@\n%@开讲",model.role, model.name, model.start_time];

}

@end
